package com.pan.admin.module.api.service.impl;

import com.pan.admin.common.utils.DateUtils;
import com.pan.admin.module.api.dao.ApiRequiredRuleDao;
import com.pan.admin.module.api.entity.ApiRequiredRule;
import com.pan.admin.module.api.service.ApiRequiredRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


/**
 * api必填字段规则Service业务层处理
 *
 * @author ts
 * @date 2023-10-30
 */
@Service
public class ApiRequiredRuleServiceImpl implements ApiRequiredRuleService {

    @Autowired
    private ApiRequiredRuleDao apiRequiredRuleDao;

    /**
     * 根据ID获取列表api必填字段规则
     *
     * @param id api必填字段规则主键
     * @return api必填字段规则
     */
    @Override
    @Transactional(readOnly = true)
    public ApiRequiredRule getById(Long id) {
        return apiRequiredRuleDao.getById(id);
    }

    /**
     * 查询api必填字段规则列表
     *
     * @param apiRequiredRule api必填字段规则
     * @return api必填字段规则
     */
    @Override
    @Transactional(readOnly = true)
    public List<ApiRequiredRule> list(ApiRequiredRule apiRequiredRule) {
        return apiRequiredRuleDao.list(apiRequiredRule);
    }

    @Override
    @Transactional(readOnly = true)
    public List<ApiRequiredRule> listAndForm(ApiRequiredRule apiRequiredRule) {
        return apiRequiredRuleDao.listAndForm(apiRequiredRule);
    }

    /**
     * 新增api必填字段规则
     *
     * @param apiRequiredRule api必填字段规则
     * @return 结果
     */
    @Override
    public int insertApiRequiredRule(ApiRequiredRule apiRequiredRule) {
        apiRequiredRule.setCreateTime(DateUtils.getNowDate());
        return apiRequiredRuleDao.insertApiRequiredRule(apiRequiredRule);
    }

    /**
     * 修改api必填字段规则
     *
     * @param apiRequiredRule api必填字段规则
     * @return 结果
     */
    @Override
    public int updateApiRequiredRule(ApiRequiredRule apiRequiredRule) {
        return apiRequiredRuleDao.updateApiRequiredRule(apiRequiredRule);
    }

    /**
     * 批量删除api必填字段规则
     *
     * @param ids 需要删除的api必填字段规则主键
     * @return 结果
     */
    @Override
    public int batchDeleteById(Long[] ids) {
        return apiRequiredRuleDao.batchDeleteById(ids);
    }

    /**
     * 删除api必填字段规则信息
     *
     * @param id api必填字段规则主键
     * @return 结果
     */
    @Override
    public int deleteById(Long id) {
        return apiRequiredRuleDao.deleteById(id);
    }
}
